import { TimeUtils } from "../Utils/TimeUtils";

/**
 * 日志管理类
 */
class LogMgr {

    public static instance: LogMgr = null
    public static getInstance() {
        if (!LogMgr.instance) {
            LogMgr.instance = new LogMgr()
        }
        return LogMgr.instance
    }

    log(message?: any, ...optionalParams: any[]) {
        console.log(`${TimeUtils.logDate()} ${message}`, ...optionalParams)
    };

    info(message?: any, ...optionalParams: any[]) {
        console.info(`${TimeUtils.logDate()} ${message}`, ...optionalParams)
    };

    warn(message?: any, ...optionalParams: any[]) {
        console.warn(`${TimeUtils.logDate()} ${message}`, ...optionalParams)
    };

    error(message?: any, ...optionalParams: any[]) {
        console.error(`${TimeUtils.logDate()} ${message}`, ...optionalParams)
    };

}

export let logMgr = LogMgr.getInstance()